package cn.ncu.wechat.controller;

import cn.ncu.wechat.model.PointsRecord;
import cn.ncu.wechat.model.dto.PointRuleDTO;
import cn.ncu.wechat.service.PointsRecordService;
import cn.ncu.wechat.service.PointsRuleService;
import cn.ncu.wechat.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/admin")
public class PointController {
    @Autowired
    private PointsRuleService pointsRuleService;

    @Autowired
    private PointsRecordService pointsRecordService;
    @GetMapping("/marketing/points/rules")
    public Result<?> getPointRle(){
        return pointsRuleService.getRule();
    }

    @PostMapping("/marketing/points/rules")
    public Result<?> upPointRle(@RequestBody PointRuleDTO pointRuleDTO){
        return pointsRuleService.setRule(pointRuleDTO);
    }

    @GetMapping("/member-points")
    public Result<?> getMemberPointsRecord(@RequestParam Integer page,@RequestParam Integer pageSize,@RequestParam Integer memberId,@RequestParam Integer type){
        if (page==null||page<=0||pageSize==null||pageSize<=0||memberId==null||memberId<=0||type==null||type<=0){
            return Result.error(400,"参数错误");
        }
        return pointsRecordService.GetRecord(page,pageSize,memberId,type);
    }

//    @GetMapping("/member-levels")
//    public Result<?> get
}
